package org.example.mq;

import org.example.config.RabbitConfig;
import org.example.entity.Order;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class SenderImpl {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    //精准查询
//    public void send1(String key, String message){
//        rabbitTemplate.convertAndSend(RabbitConfig.S59_DIRECT_EXCHANGE, key , message);
//    }

    //模糊查询
//    public void send1(String key, String message){
//        rabbitTemplate.convertAndSend(RabbitConfig.S59_TOPIC_EXCHANGE, key , message);
//    }

    //泛型（广播）
    public void send1(String key, String message){
        rabbitTemplate.convertAndSend(RabbitConfig.S59_FANOUT_EXCHANGE, key , message);
    }

    //异步订单
    public void sendOrderCreateMessage(String key, Order order ){
        rabbitTemplate.convertAndSend(RabbitConfig.S59_FANOUT_EXCHANGE, key , order);
    }
}
